Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

error-ex

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-ex

Easy error subclassing and stack customization

  • 1.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is error-ex?

The error-ex npm package is designed to create more customizable and informative error objects in JavaScript. It allows developers to extend the native Error type with additional properties and behaviors, making error handling and debugging more efficient.

What are error-ex's main functionalities?

Creating custom error types

This feature allows developers to create custom error types by extending the native Error object. The custom error can then be thrown with a specific message, making it easier to identify and handle specific kinds of errors in the code.

const ErrorEx = require('error-ex');
const MyError = ErrorEx('MyError');
throw new MyError('Something went wrong');

Adding properties to errors

This functionality enables the addition of custom properties to error objects. In this example, a 'code' property is added to a custom error type, which could be used to store HTTP status codes or other relevant error information.

const ErrorEx = require('error-ex');
const MyError = ErrorEx('MyError');
MyError.prototype.code = 404;
const errorInstance = new MyError('Resource not found');
console.log(errorInstance.code); // 404

Other packages similar to error-ex

Keywords

FAQs

Package last updated on 19 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc